﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
@model PluginModel
<ul class="breadcrumb" style="margin-bottom: 7px;">
    <li><a href="#">首页</a> <span class="divider">/</span></li>
    <li><a href="#">内容管理</a> <span class="divider">/</span></li>
    <li class="active">插件管理</li>
</ul>
<div class="row-fluid">
    <div class="span5">
        <div class="panel">
            <div class="panel-header clearfix">
                <h3 class="pull-left">插件分类</h3>
                <div class="pull-right" id="tbar">
                    <ul class="bui-bar button-group" id="bar8" role="toolbar" aria-disabled="false">
                    </ul>
                </div>
            </div>
            <div class="panel-body" id="PluginType">
            </div>
        </div>
    </div>
    <div class="span19">
        <div class="panel">
            <div class="panel-header clearfix">
                <h3 class="pull-left">模块列表</h3>
                <div class="pull-right">
                    <button id="addArticleBtn" class="button button-small button-primary">添加模块</button>
                </div>
            </div>
            <div class="panel-body" id="grid">
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    var List = BUI.List
    var data = eval('@Html.Raw(Model.PluginClass)');
    var items = [
        { text: '图片幻灯片', value: 'a' },
        { text: '站内广告', value: 'b' },
        { text: '友情链接', value: 'c' },
        { text: "文章列表", value: 3 }
    ],
      list = new List.SimpleList({
          elCls: 'bui-select-list',//默认是'bui-simple-list'
          //width: 232,
          render: '#PluginType',
          items: data
      });
    list.render();
    list.on('itemclick', function (ev) {
        //alert(ev.item.text + '：' + ev.item.value);
    });



    //列表
    var Grid = BUI.Grid,
    Store = BUI.Data.Store,
    columns = [
      { title: '模块名称', width: 200, sortable: false, dataIndex: 'Title' },
      { title: '分类', width: 100, sortable: false, dataIndex: 'CreateTime' },
      {
          title: '管理', width: 150, sortable: false, dataIndex: 'ID',
          renderer: function (value, obj) {
              return '<span class="grid-command" onclick="EditPage(\'' + value + '\')">编辑</span><span class="grid-command" onclick="DeletePage(\'' + value + '\')" >删除</span>';
          }
      }
    ];
    //加载列表
    var store = new Store({
        url: '/Admin/Plugin/AjaxGetList',
        proxy: {
            limitParam: 'pageSize',
            method: 'post'
        },
        autoLoad: true,
        pageSize: 10
    }),
    grid = new Grid.Grid({
        render: '#grid',
        loadMask: true,
        forceFit: true,
        plugins: [Grid.Plugins.AutoFit],
        columns: columns,
        store: store,
        bbar: {
            pagingBar: true
        }
    });
    grid.render();
    //搜索
    var form = $('#searchForm')[0];
    $(form).on('submit', function (ev) {
        ev.preventDefault();
        var obj = BUI.FormHelper.serializeToObject(form);
        obj.pageIndex = 0;
        obj.start = 0;
        store.load(obj);
    });
    function SubmitSuccess() {

        $('#searchForm').submit();
    }

</script>
